import {TESTADD, TODOSADD, SELECTALL, DELITEM, DELCOMPLETED, ALLSHOW, SHOWCHANGES, SETTODOS} from "./typeConst";
import localStorage from '@/ulti/localStorage'
export const actions = {
  testAdd:({commit})=>{
    commit(TESTADD);
  },
  todosAdd:(({commit},value)=>{
    commit(TODOSADD,value);
  }),
  selectAll:(({commit},value)=>{
    commit(SELECTALL,value);
  }),
  delItem:(({commit},value)=>{
    commit(DELITEM,value);
  }),
  delCompleted: (({commit})=>{
    commit(DELCOMPLETED);
  }),
  allShow:(({commit})=>{
    commit(ALLSHOW);
  }),
  showChanges: (({commit},value)=>{
    commit(SHOWCHANGES,value);
  }),
  setTodos:(({commit})=>{
    const value = localStorage.readTodos() || [];
    setTimeout(()=>{
      commit(SETTODOS,value);
    },1000)
  })
}
